import java.util.Hashtable;

class P10679 {

   static Hashtable hashtable;

   public static void main(String[] args) {

       int cases = Integer.parseInt(readLn());
       for (int k = 0; k < cases; k++) {
           process();
       }
   }

   private static void process() {
       hashtable = new Hashtable();
       String string = readLn();
       int subcases = Integer.parseInt(readLn());
       for (int k = 0; k < subcases; k++) {
           String query = readLn();
           Object answer = hashtable.get(query);
           if (answer == null) {
               if (string.indexOf(query) > -1 ) {
                   hashtable.put(query, "y");
                   System.out.println("y");
               } else {
                   hashtable.put(query, "n");
                   System.out.println("n");
               }
           } else {
               System.out.println(answer);
           }
       }
   }

   static String readLn() {
       String newLine = System.getProperty("line.separator");
       StringBuffer buffer = new StringBuffer();
       int car = -1;
       try {
           car = System.in.read();
           while ((car > 0) && (car != newLine.charAt(0))) {
               buffer.append((char)car);
               car = System.in.read();
           }
           if (car == newLine.charAt(0))
           System.in.skip(newLine.length() - 1);
       } catch (java.io.IOException e) { return (null);}
       if ((car < 0) && (buffer.length() == 0)) return (null);
       return (buffer.toString()).trim();
   }

}